package com.atguigu.gmall.manage.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.atguigu.gmall.bean.PmsBaseAttrInfo;
import com.atguigu.gmall.bean.PmsBaseAttrValue;
import com.atguigu.gmall.bean.PmsBaseSaleAttr;
import com.atguigu.gmall.service.AttrService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
public class AttrController {

   @Reference
   private AttrService attrService;

   @RequestMapping("attrInfoList")
   public List<PmsBaseAttrInfo> attrInfoList(String catalog3Id){
       List<PmsBaseAttrInfo> pmsBaseAttrInfos = this.attrService.attrInfoList(catalog3Id);
       return pmsBaseAttrInfos;
   }

   @RequestMapping("getAttrValueList")
   public List<PmsBaseAttrValue> getAttrValueList(String attrId){
        List<PmsBaseAttrValue> pmsBaseAttrValues = this.attrService.getAttrValueList(attrId);
        return pmsBaseAttrValues;
   }

   @RequestMapping("saveAttrInfo")
   public String saveAttrInfo(@RequestBody PmsBaseAttrInfo pmsBaseAttrInfo){
       String success = this.attrService.saveAttrInfo(pmsBaseAttrInfo);
       return "success";
   }

    @RequestMapping("baseSaleAttrList")
    public List<PmsBaseSaleAttr> baseSaleAttrList(){
       List<PmsBaseSaleAttr> pmsBaseSaleAttrs = this.attrService.baseSaleAttrList();
        return pmsBaseSaleAttrs;
    }
}
